//
//  InitiatorInfoView.m
//  ECBBusinessCamp
//
//  Created by rimi on 16/6/21.
//  Copyright © 2016年 邓毕华. All rights reserved.
//

#import "InitiatorInfoView.h"

@interface InitiatorInfoView ()

@property (nonatomic, strong) UILabel * fromuserLabel;
@property (nonatomic, strong) UILabel * fromuserInfoLabel;
@property (nonatomic, strong) UILabel * phoneLabel;
@property (nonatomic, strong) UILabel * phoneInfoLabel;
@property (nonatomic, strong) UILabel * qqLabel;
@property (nonatomic, strong) UILabel * qqInfoLabel;
@property (nonatomic, strong) UILabel * regionLabel;
@property (nonatomic, strong) UILabel * regionInfoLabel;
@property (nonatomic, strong) UILabel * companyNameLabel;
@property (nonatomic, strong) UILabel * companyNameInfoLabel;
@property (nonatomic, strong) UILabel * positionLabel;
@property (nonatomic, strong) UILabel * positionInfoLabel;

@end

@implementation InitiatorInfoView

#pragma mark 🌷🌷🌷life cycle🌷🌷🌷
- (instancetype)initWithInitiatorInfo:(NSDictionary *)initiatorInfo
{
    self = [super init];
    if (self) {
        // 添加视图
        [self addSubview:self.fromuserLabel];
        [self addSubview:self.fromuserInfoLabel];
        [self addSubview:self.phoneLabel];
        [self addSubview:self.phoneInfoLabel];
        [self addSubview:self.qqLabel];
        [self addSubview:self.qqInfoLabel];
        [self addSubview:self.regionLabel];
        [self addSubview:self.regionInfoLabel];
        [self addSubview:self.companyNameLabel];
        [self addSubview:self.companyNameInfoLabel];
        [self addSubview:self.positionLabel];
        [self addSubview:self.positionInfoLabel];
        
        // 自动布局
        [_fromuserLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.left.offset(0);
        }];
        [_fromuserInfoLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerY.equalTo(_fromuserLabel);
            make.left.equalTo(_fromuserLabel.mas_right);
        }];
        [_phoneLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.equalTo(_fromuserLabel);
            make.top.offset(SCREEN_HEIGHT * 0.05);
        }];
        [_phoneInfoLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerY.equalTo(_phoneLabel);
            make.left.equalTo(_phoneLabel.mas_right);
        }];
        [_qqLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.equalTo(_fromuserLabel);
            make.top.offset(SCREEN_HEIGHT * 0.1);
        }];
        [_qqInfoLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerY.equalTo(_qqLabel);
            make.left.equalTo(_qqLabel.mas_right);
        }];
        [_regionLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(_fromuserLabel);
            make.right.equalTo(_companyNameLabel);
        }];
        [_regionInfoLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerY.equalTo(_regionLabel);
            make.left.equalTo(_regionLabel.mas_right);
        }];
        [_companyNameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.mas_centerX);
            make.top.equalTo(_phoneLabel);
        }];
        [_companyNameInfoLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerY.equalTo(_companyNameLabel);
            make.left.equalTo(_companyNameLabel.mas_right);
        }];
        [_positionLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(_qqLabel);
            make.right.equalTo(_companyNameLabel);
        }];
        [_positionInfoLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerY.equalTo(_positionLabel);
            make.left.equalTo(_positionLabel.mas_right);
        }];
        
        // 加载数据
        _fromuserInfoLabel.text = initiatorInfo[@"username"];
        _phoneInfoLabel.text = initiatorInfo[@"phone"];
        _qqInfoLabel.text = initiatorInfo[@"qq"];
        _regionInfoLabel.text = initiatorInfo[@"addr"];
        _companyNameInfoLabel.text = initiatorInfo[@"company"];
        _positionInfoLabel.text = initiatorInfo[@"jog"];
    }
    return self;
}
#pragma mark 🌷🌷🌷getters and setters🌷🌷🌷
- (UILabel *)fromuserLabel {
    if (!_fromuserLabel) {
        _fromuserLabel = [[UILabel alloc] init];
        _fromuserLabel.text = @"发起人：";
        _fromuserLabel.font = [UIFont systemFontOfSize:25];
    }
    return _fromuserLabel;
}
- (UILabel *)fromuserInfoLabel {
    if (!_fromuserInfoLabel) {
        _fromuserInfoLabel = [[UILabel alloc] init];
        _fromuserInfoLabel.font = [UIFont systemFontOfSize:25];
    }
    return _fromuserInfoLabel;
}
- (UILabel *)phoneLabel {
    if (!_phoneLabel) {
        _phoneLabel = [[UILabel alloc] init];
        _phoneLabel.text = @"手机号：";
        _phoneLabel.font = [UIFont systemFontOfSize:25];
    }
    return _phoneLabel;
}
- (UILabel *)phoneInfoLabel {
    if (!_phoneInfoLabel) {
        _phoneInfoLabel = [[UILabel alloc] init];
        _phoneInfoLabel.font = [UIFont systemFontOfSize:25];
    }
    return _phoneInfoLabel;
}
- (UILabel *)qqLabel {
    if (!_qqLabel) {
        _qqLabel = [[UILabel alloc] init];
        _qqLabel.text = @"QQ：";
        _qqLabel.font = [UIFont systemFontOfSize:25];
    }
    return _qqLabel;
}
- (UILabel *)qqInfoLabel {
    if (!_qqInfoLabel) {
        _qqInfoLabel = [[UILabel alloc] init];
        _qqInfoLabel.font = [UIFont systemFontOfSize:25];
    }
    return _qqInfoLabel;
}
- (UILabel *)regionLabel {
    if (!_regionLabel) {
        _regionLabel = [[UILabel alloc] init];
        _regionLabel.text = @"地区：";
        _regionLabel.font = [UIFont systemFontOfSize:25];
    }
    return _regionLabel;
}
- (UILabel *)regionInfoLabel {
    if (!_regionInfoLabel) {
        _regionInfoLabel = [[UILabel alloc] init];
        _regionInfoLabel.font = [UIFont systemFontOfSize:25];
    }
    return _regionInfoLabel;
}
- (UILabel *)companyNameLabel {
    if (!_companyNameLabel) {
        _companyNameLabel = [[UILabel alloc] init];
        _companyNameLabel.text = @"公司名称：";
        _companyNameLabel.font = [UIFont systemFontOfSize:25];
    }
    return _companyNameLabel;
}
- (UILabel *)companyNameInfoLabel {
    if (!_companyNameInfoLabel) {
        _companyNameInfoLabel = [[UILabel alloc] init];
        _companyNameInfoLabel.font = [UIFont systemFontOfSize:25];
    }
    return _companyNameInfoLabel;
}
- (UILabel *)positionLabel {
    if (!_positionLabel) {
        _positionLabel = [[UILabel alloc] init];
        _positionLabel.text = @"职位：";
        _positionLabel.font = [UIFont systemFontOfSize:25];
    }
    return _positionLabel;
}
- (UILabel *)positionInfoLabel {
    if (!_positionInfoLabel) {
        _positionInfoLabel = [[UILabel alloc] init];
        _positionInfoLabel.font = [UIFont systemFontOfSize:25];
    }
    return _positionInfoLabel;
}


@end
